package com.ocm.core.domain;

import com.ocm.core.exception.ExceptionCode;
import com.ocm.core.exception.UnsupportTypeException;
import com.ocm.core.exception.TypeCodeException;

/**
 * 
 * @author Quan Vo
 * Sep 25, 2009
 */
public enum ClassDefinitionType {
   DOCUMENTCLASSDEF(0), CUSTOMOBJECTDEF(1), DOCUMENTCLASSINST(2), CUSTOMOBJECTINST(3);

   private int classDefType;

   public int getClassDefType() {
      return classDefType;
   }

   private ClassDefinitionType(int classDefType) {
      this.classDefType = classDefType;
   }

   public static ClassDefinitionType getClassDefType(int type) throws UnsupportTypeException {
      ClassDefinitionType classDefType = null;
      switch (type) {
         case 0:
            classDefType = ClassDefinitionType.DOCUMENTCLASSDEF;
            break;
         case 1:
            classDefType = ClassDefinitionType.CUSTOMOBJECTDEF;
            break;
         case 2:
            classDefType = ClassDefinitionType.DOCUMENTCLASSINST;
            break;
         case 3:
            classDefType = ClassDefinitionType.CUSTOMOBJECTINST;
            break;
         default:
            throw new UnsupportTypeException(ExceptionCode.instance(TypeCodeException.class,
                  TypeCodeException.CLASSDEF));
      }
      return classDefType;
   }
}
